import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:myapp/page/SearchCouponPage.dart';
import 'package:myapp/page/home/HomePage.dart';

class MainPage extends StatefulWidget {
  @override
  _MainPageState createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  final items = [
    BottomNavigationBarItem(icon: Icon(Icons.search), title: Text('搜券')),
    BottomNavigationBarItem(icon: Icon(Icons.shopping_basket), title: Text('推荐')),
//    BottomNavigationBarItem(icon: Icon(Icons.more_horiz), title: Text('更多'))
  ];

  final bodyList = [SearchCouponPage(),HomePage()];

  int currentIndex = 0;

  void onTap(int index) {
    setState(() {
      currentIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: BottomNavigationBar(
          items: items,
          currentIndex: currentIndex,
          onTap: onTap
      ),
      body:
      IndexedStack(
        index: currentIndex,
        children: bodyList,
      ),
    );
  }
}
